package com.bilibili.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.entity.CommonResult;
import com.bilibili.service.DanmakuService;
import com.bilibili.service.impl.DanmakuServiceImpl;

@SuppressWarnings("serial")
@WebServlet("/deleteDanmakuB")
public class DeleteDanmakuBServlet extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("application/json; charset=utf-8");
		String danmakuId = request.getParameter("danmakuId");
		int danmaku_id = -1;
		
		if(danmakuId != null && !"".equals(danmakuId)) {
			danmaku_id = Integer.parseInt(danmakuId);
		}
		
		DanmakuService ds = new DanmakuServiceImpl();
		CommonResult cr = new CommonResult();
		if(ds.deleteDanmakuB(danmaku_id)) {
			cr.setCode(200);
		}else {
			cr.setCode(409);
		}
		response.getWriter().write(cr.toJSONString());
	}
}
